package com.demo.server.impl;

import com.demo.mapper.UserMapper;
import com.demo.pojo.User;
import com.demo.server.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;
    @Override
    public User findUser(Long id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> findUserList() {
        return userMapper.selectByExample(null);
    }

    @Override
    public Boolean addUser(User user) {
        int insert = userMapper.insert(user);
        if (insert!=0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean deleteUser(Long id) {
        int i = userMapper.deleteByPrimaryKey(id);
        if (i!=0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean updateUser(User user) {
        int i = userMapper.updateByPrimaryKey(user);
        if (i!=0){
            return true;
        }
        return false;
    }
}
